<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>QCNSim: QcnSim/Route.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">QCNSim
   </div>
   <div id="projectbrief">Simulator for Quake-Catcher Network</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d21be12960473ba5c51e5f9beea3525e.html">QcnSim</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Route.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_route_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_route_8h.html">Route.h</a>&quot;</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;</div>
<div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="class_route.html#a2b1c971aaf032109cee8081c97e9b9e9">   25</a></span>&#160;<a class="code" href="class_route.html#a2b1c971aaf032109cee8081c97e9b9e9">Route::Route</a>(): explicitRoute(), explicitRouteNextHopIndex(), recordedRoute() {</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;}</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="class_route.html#a2d3e3957f18c1658494df28a47c31891">   36</a></span>&#160;<a class="code" href="class_route.html#a2b1c971aaf032109cee8081c97e9b9e9">Route::Route</a>(std::vector&lt;std::shared_ptr&lt;Entity&gt;&gt; explicitRoute): explicitRoute(explicitRoute), recordedRoute(), explicitRouteNextHopIndex(0) {</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;}</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div>
<div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="class_route.html#a0f045eb09f6f8cd861eec4a6a2ab6162">   44</a></span>&#160;std::vector&lt;std::shared_ptr&lt;Entity&gt;&gt; <a class="code" href="class_route.html#a0f045eb09f6f8cd861eec4a6a2ab6162">Route::getExplicitRoute</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_route.html#aa2dd022debe37b4f2e0b1d292756b481">explicitRoute</a>;</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;}</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="comment">// * @brief Get value of flag recordThisRoute.</span></div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;<span class="comment">// *</span></div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="comment">// * @return True is route is being recorded; false if route is not being recorded.</span></div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;<span class="comment">// */</span></div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="comment">//bool Route::isRouteBeingRecorded() const {</span></div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;<span class="comment">//  return recordThisRoute;</span></div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;<span class="comment">//}</span></div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;</div>
<div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="class_route.html#a423fa64c12ce8c6a3814f88e78fdf713">   62</a></span>&#160;std::vector&lt;std::shared_ptr&lt;Entity&gt;&gt; <a class="code" href="class_route.html#a423fa64c12ce8c6a3814f88e78fdf713">Route::getRecordedRoute</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_route.html#a6489904d8f11f6c7e10ff391c7c50a30">recordedRoute</a>;</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;}</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div>
<div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="class_route.html#aea208ca1d1beea85359d6bd39eb142fb">   71</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_route.html#aea208ca1d1beea85359d6bd39eb142fb">Route::setExplicitRoute</a>(std::vector&lt;std::shared_ptr&lt;Entity&gt;&gt; explicitRoute) {</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    this-&gt;<a class="code" href="class_route.html#aa2dd022debe37b4f2e0b1d292756b481">explicitRoute</a> = <a class="code" href="class_route.html#aa2dd022debe37b4f2e0b1d292756b481">explicitRoute</a>;</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    <a class="code" href="class_route.html#aeb06471ef9e90e1a6f24cbf8ad214f2a">explicitRouteNextHopIndex</a> = 0;</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;}</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;<span class="comment">// * @brief Set flag to record the route followed by token to TRUE.</span></div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;<span class="comment">// */</span></div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;<span class="comment">//void Route::setRecordThisRoute() {</span></div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;<span class="comment">//  recordThisRoute = true;</span></div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;<span class="comment">//}</span></div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;<span class="comment">// * @brief Unset flag to record the route followed by token (set to FALSE).</span></div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;<span class="comment">// */</span></div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="comment">//void Route::setDoNotRecordThisRoute() {</span></div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;<span class="comment">//  recordThisRoute = false;</span></div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;<span class="comment">//}</span></div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;</div>
<div class="line"><a name="l00099"></a><span class="lineno"><a class="line" href="class_route.html#a4fb075c7ea3e111c16bfd5222fa5074c">   99</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_route.html#a4fb075c7ea3e111c16bfd5222fa5074c">Route::addHopToRecordedRoute</a>(std::shared_ptr&lt;Entity&gt; hop) {</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    <a class="code" href="class_route.html#a6489904d8f11f6c7e10ff391c7c50a30">recordedRoute</a>.push_back(hop);</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;}</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;</div>
<div class="line"><a name="l00114"></a><span class="lineno"><a class="line" href="class_route.html#a7c1ae064ef11575ae6d75feebadb8777">  114</a></span>&#160;std::shared_ptr&lt;Entity&gt; <a class="code" href="class_route.html#a7c1ae064ef11575ae6d75feebadb8777">Route::getNextHopFromExplicitRoute</a>() {</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="class_route.html#aa2dd022debe37b4f2e0b1d292756b481">explicitRoute</a>.empty()) {</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">nullptr</span>; <span class="comment">// No explicit route; return nullptr.</span></div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;    }</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    <span class="comment">// If index points to end(), then return the last hop.</span></div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="class_route.html#aeb06471ef9e90e1a6f24cbf8ad214f2a">explicitRouteNextHopIndex</a> &gt;= <a class="code" href="class_route.html#aa2dd022debe37b4f2e0b1d292756b481">explicitRoute</a>.size()) {</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="class_route.html#aa2dd022debe37b4f2e0b1d292756b481">explicitRoute</a>.back();</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    }</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    <span class="keywordtype">size_t</span> currentNextHopIndex = <a class="code" href="class_route.html#aeb06471ef9e90e1a6f24cbf8ad214f2a">explicitRouteNextHopIndex</a>; <span class="comment">// Get next hop index before we increment it.</span></div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    ++<a class="code" href="class_route.html#aeb06471ef9e90e1a6f24cbf8ad214f2a">explicitRouteNextHopIndex</a>; <span class="comment">// Advance index to hop after next.</span></div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_route.html#aa2dd022debe37b4f2e0b1d292756b481">explicitRoute</a>.at(currentNextHopIndex);</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;}</div>
<div class="ttc" id="class_route_html_aea208ca1d1beea85359d6bd39eb142fb"><div class="ttname"><a href="class_route.html#aea208ca1d1beea85359d6bd39eb142fb">Route::setExplicitRoute</a></div><div class="ttdeci">void setExplicitRoute(std::vector&lt; std::shared_ptr&lt; Entity &gt;&gt; explicitRoute)</div><div class="ttdoc">Set explicit route token must follow. </div><div class="ttdef"><b>Definition:</b> <a href="_route_8cpp_source.html#l00071">Route.cpp:71</a></div></div>
<div class="ttc" id="class_route_html_a423fa64c12ce8c6a3814f88e78fdf713"><div class="ttname"><a href="class_route.html#a423fa64c12ce8c6a3814f88e78fdf713">Route::getRecordedRoute</a></div><div class="ttdeci">std::vector&lt; std::shared_ptr&lt; Entity &gt; &gt; getRecordedRoute() const </div><div class="ttdoc">Get value of flag recordThisRoute. </div><div class="ttdef"><b>Definition:</b> <a href="_route_8cpp_source.html#l00062">Route.cpp:62</a></div></div>
<div class="ttc" id="class_route_html_a0f045eb09f6f8cd861eec4a6a2ab6162"><div class="ttname"><a href="class_route.html#a0f045eb09f6f8cd861eec4a6a2ab6162">Route::getExplicitRoute</a></div><div class="ttdeci">std::vector&lt; std::shared_ptr&lt; Entity &gt; &gt; getExplicitRoute() const </div><div class="ttdoc">Get explicit route. </div><div class="ttdef"><b>Definition:</b> <a href="_route_8cpp_source.html#l00044">Route.cpp:44</a></div></div>
<div class="ttc" id="class_route_html_aa2dd022debe37b4f2e0b1d292756b481"><div class="ttname"><a href="class_route.html#aa2dd022debe37b4f2e0b1d292756b481">Route::explicitRoute</a></div><div class="ttdeci">std::vector&lt; std::shared_ptr&lt; Entity &gt; &gt; explicitRoute</div><div class="ttdoc">Vector containing a list of Entity objects representing the route to be followed by a token/PDU...</div><div class="ttdef"><b>Definition:</b> <a href="_route_8h_source.html#l00037">Route.h:37</a></div></div>
<div class="ttc" id="_route_8h_html"><div class="ttname"><a href="_route_8h.html">Route.h</a></div></div>
<div class="ttc" id="class_route_html_aeb06471ef9e90e1a6f24cbf8ad214f2a"><div class="ttname"><a href="class_route.html#aeb06471ef9e90e1a6f24cbf8ad214f2a">Route::explicitRouteNextHopIndex</a></div><div class="ttdeci">size_t explicitRouteNextHopIndex</div><div class="ttdoc">Index pointing to the next Entity to which the token/PDU is to be forwarded. </div><div class="ttdef"><b>Definition:</b> <a href="_route_8h_source.html#l00039">Route.h:39</a></div></div>
<div class="ttc" id="class_route_html_a7c1ae064ef11575ae6d75feebadb8777"><div class="ttname"><a href="class_route.html#a7c1ae064ef11575ae6d75feebadb8777">Route::getNextHopFromExplicitRoute</a></div><div class="ttdeci">std::shared_ptr&lt; Entity &gt; getNextHopFromExplicitRoute()</div><div class="ttdoc">Gets the next hop from the explicit route vector. </div><div class="ttdef"><b>Definition:</b> <a href="_route_8cpp_source.html#l00114">Route.cpp:114</a></div></div>
<div class="ttc" id="class_route_html_a4fb075c7ea3e111c16bfd5222fa5074c"><div class="ttname"><a href="class_route.html#a4fb075c7ea3e111c16bfd5222fa5074c">Route::addHopToRecordedRoute</a></div><div class="ttdeci">void addHopToRecordedRoute(std::shared_ptr&lt; Entity &gt; hop)</div><div class="ttdoc">Set flag to record the route followed by token to TRUE. </div><div class="ttdef"><b>Definition:</b> <a href="_route_8cpp_source.html#l00099">Route.cpp:99</a></div></div>
<div class="ttc" id="class_route_html_a2b1c971aaf032109cee8081c97e9b9e9"><div class="ttname"><a href="class_route.html#a2b1c971aaf032109cee8081c97e9b9e9">Route::Route</a></div><div class="ttdeci">Route()</div><div class="ttdoc">Default constructor. </div><div class="ttdef"><b>Definition:</b> <a href="_route_8cpp_source.html#l00025">Route.cpp:25</a></div></div>
<div class="ttc" id="class_route_html_a6489904d8f11f6c7e10ff391c7c50a30"><div class="ttname"><a href="class_route.html#a6489904d8f11f6c7e10ff391c7c50a30">Route::recordedRoute</a></div><div class="ttdeci">std::vector&lt; std::shared_ptr&lt; Entity &gt; &gt; recordedRoute</div><div class="ttdoc">Route that was followed by token/PDU, currently being recorded. </div><div class="ttdef"><b>Definition:</b> <a href="_route_8h_source.html#l00042">Route.h:42</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Jan 6 2014 12:30:37 for QCNSim by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.5
</small></address>
</body>
</html>
